﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core;
using Core.LockStep;
using UnityEngine;

[BackupDataId(1)]
public class BackupData1PlayerData : BackupData<BackupData1PlayerData>
{
    public int playerId;
    public Vector3IntData position = new Vector3IntData();
    public TransformData model = new TransformData();

    public override void Clear()
    {
        playerId = 0;
        position.Clear();
        model.Clear();
    }

    public override void InterpolationEnd()
    {
        position.InterpolationEnd();
    }

    public override BackupData1PlayerData ReadFrom(IFrameDataStream stream)
    {
        playerId = stream.ReadInt32();
        position.ReadFrom(stream);
        model.ReadFrom(stream);
        return this;
    }

    public override void WriteTo(IFrameDataStream stream)
    {
        stream.WriteInt32(playerId);
        position.WriteTo(stream);
        model.WriteTo(stream);
    }

    public override string GetDescription()
    {
        var builder = new StringBuilder();

        builder.AppendLine($"InstanceId:{InstanceId}, playerId:{playerId}, pos:({position.Last},{position.Current}), model:{model.ReferenceId}");

        return builder.ToString();
    }
}